package com.situ.crm.controller.back;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.situ.crm.common.ServerResponse;
import com.situ.crm.entity.CusDevPlan;
import com.situ.crm.service.ICusDevPlanService;
import com.situ.crm.service.ICustomerService;
import com.situ.crm.service.ISaleChanceService;

@Controller
@RequestMapping("/cusdevplan")
public class CusDevPlanController {

	@Autowired
	private ICusDevPlanService cusDevPlanService;
	@Autowired
	private ISaleChanceService saleChanceService;
	// getCusdevplanPage
	// 跳转到开发界面
	@RequestMapping("/getCusdevplanPage")
	public String getCusdevplanPage(Integer id,Model model) {
		System.out.println("saleChanceId = "+id);
		model.addAttribute("saleChanceId", id);
		return "/salechance/cusdevplan";
	}

	// 跳转到cusdevplan展示界面 不分页了
	// 携带ID sale_chance 表中ID == cus_dev_plan表中sale_chance_id
	@RequestMapping("/getCusDevPlanPageList")
	@ResponseBody
	public ServerResponse getCusDevPlanPage(Integer id) {
		System.out.println("数据接口id = "+id);
		ServerResponse serverResponse = cusDevPlanService.list(id);
		return serverResponse;
	}

	// 跳转到添加界面
	@RequestMapping("/add")
	public String add(Integer saleChanceId) {
		System.out.println("saleChanceId ="+saleChanceId);
		return "/salechance/cusdevplan_add";
	}
	// 添加功能
	@RequestMapping("/insert")
	@ResponseBody
	public ServerResponse insert(CusDevPlan cusDevPlan) {
		/*Date time = Date;
		System.out.println("time =" + time);
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmssSSS");
		// 以现在的时间作为OrderNo
		String orderNoStr = sdf.format(time);
		long orderNo = Long.parseLong(orderNoStr);
		System.out.println("orderNo = " + orderNo);*/

		ServerResponse serverResponse = cusDevPlanService.insert(cusDevPlan);

		return serverResponse;
	}
}
